package homework3;

import java.util.Scanner;

//求2个整数的最大公约数
public class P9 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt(), n = sc.nextInt();
        int min = m > n ? n : m;
        for (int i = min; i>=1; i--) {
            if (m % i == 0 && n % i == 0) {
                System.out.println(i);
                break;
            }
        }
        sc.close();
    }
}
